#include <iostream>
#include <algorithm>
using namespace std;

const int N = 1001;
const int INF = ~(1 << 31);
int f[N][N], g[N][N], a[N][N];
char tf[N][N], tg[N][N];

int dis(int x, int y)
{
	int t = 0;
	while (!(x%y) && x) {
		++t;
		x /= y;
	}
	return t;
}

void print(int x, int y, char (*t)[N])
{
	if (x || y) {
		if (t[x][y] == 'R') print(x, y-1, t);
		if (t[x][y] == 'D') print(x-1, y, t);
		cout << t[x][y];
	}
}

int main()
{

	fill(f[0], f[0] + N*N, INF);
	fill(g[0], g[0] + N*N, INF);
	int n, px;
	cin >> n;
	bool zero = false;
	for (int i = 0; i != n; ++i)
		for (int j = 0; j != n; ++j) {
			cin >> a[i][j];
			if (!a[i][j]) {
				zero = true;
				px = i;
			}
		}

	f[0][0] = dis(a[0][0], 2); g[0][0] = dis(a[0][0], 5);
	for (int i = 0; i != n; ++i)
		for (int j = 0; j != n; ++j) {
			if (i != 0) {
				f[i][j] = f[i - 1][j];
				tf[i][j] = 'D';
				g[i][j] = g[i - 1][j];
				tg[i][j] = 'D';
			}
			if (j != 0) {
				if (f[i][j - 1] < f[i][j]) {
					f[i][j] = f[i][j - 1];
					tf[i][j] = 'R';
				}
				if (g[i][j - 1] < g[i][j]) {
					g[i][j] = g[i][j - 1];
					tg[i][j] = 'R';
				}
			}
			if (!i && !j) continue;
			f[i][j] += dis(a[i][j], 2); g[i][j] += dis(a[i][j], 5);
		}
	if (min(f[n-1][n-1], g[n-1][n-1]) > 1 && zero) {
		cout << 1 << endl;
		for (int i = 0; i != px; ++i) cout << 'D';
		for (int i = 1; i != n; ++i) cout << 'R';
		for (int i = px + 1; i != n; ++i) cout << 'D';
	} else
	if (f[n - 1][n - 1] < g[n - 1][n - 1]) {
		cout << f[n - 1][n - 1] << endl;
		print(n - 1, n - 1, tf);
	} else {
		cout << g[n - 1][n - 1] << endl;
		print(n - 1, n - 1, tg);
	}
}

